func partitionLabels(s string) []int {
    ans := make([]int, 0)
    hashMap := make(map[rune]int)
    for i, v := range s {
        hashMap[v-'a'] = i
    }
    preMax := 0
    currMax := math.MinInt
    for i, v := range s {
        if currMax < hashMap[v-'a']{
            currMax = hashMap[v-'a']
        }
        if currMax == i {
            ans = append(ans, i - preMax + 1)
            preMax = currMax + 1
        }
    }
    
    return ans
}